import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  // history 模式 -> createWebHistory()       地址栏不带#
  // hash   模式  -> createWebHashHistory()   地址栏带#
  // 参数为: import.meta.env.BASE_URL -> '/'
  // vite 中的环境变量  import.meta.env.BASE_URL 就是 vite.config.js 中的 base 配置项
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    { path: '/login', component: () => import('@/views/login/index.vue') },
    {
      path: '/',
      component: () => import('@/views/layout/LayoutContainer.vue'),
      redirect: '/article/manage',
      children: [
        {
          path: '/article/manage',
          component: () => import('@/views/article/ArticleManage.vue')
        },
        {
          path: '/user/profile',
          component: () => import('@/views/user/UserProfile.vue')
        },
        {
          path: '/user/avatar',
          component: () => import('@/views/user/UserAvatar.vue')
        },
        {
          path: '/user/password',
          component: () => import('@/views/user/UserPassword.vue')
        }
      ]
    }
  ]
})

export default router
